﻿Ext.define('GS.view.user.EditProfile', {
    extend: 'Ext.form.FormPanel',
    xtype: 'editprofile',

    config: {

        title: 'Rediger',
        iconCls: 'user',

        listeners: {
            show: function () {
                var user = Ext.getStore('userData');
                user.load();
                this.setValues({
                    first_name: user.getAt(0).get('first_name'),
                    last_name: user.getAt(0).get('last_name'),
                    email: user.getAt(0).get('email'),
                    school: user.getAt(0).get('school_id'),
                });
            }
        },

        items: [
        {
            xtype: 'titlebar',
            title: 'Rediger',
            docked: 'top',
            items:
            {
                xtype: 'button',
                text: 'Tilbage',
                ui: 'back',
                id: 'btnCancelEditProfile'
            }
        },
        {
            xtype: 'textfield',
            name: 'first_name',
            //label: 'Navn',
            placeHolder: 'Fornavn',
            autoCapitalize: true,
            required: true,
            clearIcon: true,
            margin: '10 0 10 0'
        },
        {
            xtype: 'textfield',
            name: 'last_name',
            //label: 'Navn',
            placeHolder: 'Efternavn',
            autoCapitalize: true,
            required: true,
            clearIcon: true,
            margin: '10 0 10 0'
        },
        {
            xtype: 'passwordfield',
            name: 'password',
            //label: 'Kodeord',
            placeHolder: 'Kodeord',
            required: true,
            clearIcon: true,
            margin: '10 0 10 0'
        },
        {
            xtype: 'emailfield',
            name: 'email',
            //label: 'E-mail',
            placeHolder: 'E-mail',
            clearIcon: true,
            margin: '10 0 10 0'
        },
        {
            xtype: 'selectfield',
            name: 'school',
            displayField : 'name',
            valueField : 'id',
            //label: 'Institution',
            required: true,
            margin: '10 0 10 0',

            store: 'institutions',
               
        },
        {
            xtype: 'button',
            text: 'Opdater',
            ui: 'confirm',
            id: 'btnUpdateProfile',
            margin: '10 0 10 0'
        }]
    }
});